package com.yantong.constant;

import java.util.*;

/**
 * 商品类型
 */
public enum ProductType {
    Normal(0, "普通商品"),
    Spresell(1, "预售商品"),
    Spellgroup(2, "拼团商品"),
    Miaosha(3, "秒杀商品"),
    Yuyue(4, "预约商品"),
    Score(5, "积分兑换商品"),
    //添加修正商品类型
    WaiMai(6, "外卖商品"),
    TangShi(7, "堂食商品"),
    Ziti(8, "自提商品"),
    partner(9, "合伙人商品"),
    Package(10, "优惠套装商品"),
    FreeCharge(11, "免单活动商品"),
    MiningMachine(12, "矿机"),
    MortgageMining(13, "抵押挖矿"),;


    private int type;
    private String name;


    private static Map<Integer, String> all = new HashMap<>();

    static {
        for (ProductType ticketType : EnumSet.allOf(ProductType.class)) {
            all.put(ticketType.type, ticketType.name);
        }
    }

    public static String get(Integer code) {
        return all.get(code);
    }


    public static List<Map<String, Object>> listTicketTypes() {
        List<Map<String, Object>> list = new ArrayList<>();

        for (ProductType ticketType : EnumSet.allOf(ProductType.class)) {
            Map<String, Object> item = new HashMap<>();
            item.put("type", ticketType.getType());
            item.put("name", ticketType.getName());
            list.add(item);
        }
        return list;
    }

    ProductType(int type, String name) {
        this.type = type;
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
